#ifndef ESDL_SPRITE_EVENTS_H
#define ESDL_SPRITE_EVENTS_H

#include "../system/events.h"

// Bubbling
/**
 * @brief Add a new listener on a specific event
 * @param Sprite * sprite - The spite to monitor
 * @param EventType eventType - The event type which will trigger the callback
 * @param void(*callback)(Event *) - The callback function which will be executed when the event is triggered
 * @param bool capturing - if true, the callback is executed during the capturing phase. Else, it's executed during the bubbling phase
 */
void esdlAddListener(struct EsdlSprite*, EsdlEventType, EsdlEventCallback callback, bool capturing);

/**
 * @brief Remove the listener of a specific event
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param EventType eventType - The type of the event the lister is listeneing
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 * @param bool capturing - if true, this function try to remove the listener from the capturing listener list. Else, from the bubbling capturing list
 */
void esdlRemoveListener(struct EsdlSprite*, EsdlEventType, EsdlEventCallback callback, bool capturing);



/**
 * @brief Listen on a bubbling onFocus event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnFocus(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onBlur event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnBlur(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onKeyUp event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnKeyUp(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onKeyDown event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnKeyDown(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onMouseUp event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnMouseUp(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onMouseDown event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnMouseDown(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onMouseEnter event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnMouseEnter(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onMouseLeave event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnMouseLeave(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Listen on a bubbling onMouseMove event on sprite
 * @param Sprite * sprite - The sprite on which the event should be catch
 * @param void(*callback)(Event *) - The callback function to execute when the event is triggered
 */
void esdlAddListenerOnMouseMove(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onFocus event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnFocus(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onBlur event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnBlur(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onKeyUp event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnKeyUp(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onKeyDown event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnKeyDown(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onMouseUp event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnMouseUp(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onMouseDown event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnMouseDown(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onMouseEnter event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnMouseEnter(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onMouseLeave event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnMouseLeave(EsdlSprite* sprite, EsdlEventCallback callback);

/**
 * @brief Remove the listener of the bubbling onMouseMove event on sprite
 * @param Sprite * sprite - The sprite on which the event listener should be removed
 * @param void(*callback)(Event *) - The callback function to remove from the listeners list
 */
void esdlRemoveListenerOnMouseMove(EsdlSprite* sprite, EsdlEventCallback callback);

#endif
